package lijun;

public class Triangle {
    private double sideA;
    private double sideB;
    private double sideC;

    public Triangle() {
        this.sideA = 1;
        this.sideB = 1;
        this.sideC = 1;
    }

    public Triangle(double sideA, double sideB, double sideC) throws Exception {
        this.sideA = sideA;
        this.sideB = sideB;
        this.sideC = sideC;
        if (!JudgeAngle(sideA, sideB, sideC)) {
            throw new Exception("不能构成三角形！！");
        }
    }

    public double getArea() {
        double s = sideA + sideB + sideC;
        return Math.sqrt(s * (s - sideA) * (s - sideB) * (s - sideC));
    }

    public  double getLength() {
        return (sideA + sideB + sideC) / 2;
    }

    public  boolean JudgeAngle(double a, double b, double c) {

        if (a + b > c && a + c > b && b + c > a) {
            return true;
        } else {
            return false;
        }
    }
}
